package cj.web.yc.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.yc.domain.PayHistory;

/**
 * 
 * @author 
 *
 */
@DAO
public interface PayHistoryDAO{
	
	@SQL("SELECT a.*,b.name as memberName,b.phone as memberPhone,c.orderNo as orderNo FROM PayHistory a "
			+ "left join Member b on a.memberId=b.id "
			+ "left join VideoOrder c on a.orderId=b.id "
			+ "WHERE 1=1 #if(:t.memberName != null){ AND b.name LIKE '%##(:t.memberName)%' } ORDER BY createAt DESC LIMIT :t.start,:t.length ")
    List<PayHistory> query(@SQLParam("t") PayHistory payHistory);
	
	@SQL("SELECT count(1) as memberName FROM PayHistory a left join Member b on a.memberId=b.id WHERE 1=1 #if(:t.memberName != null){ AND b.name LIKE '%##(:t.memberName)%' } ")
    int querySize(@SQLParam("t") PayHistory payHistory);
    
    @SQL("SELECT * FROM PayHistory WHERE id=:1 ")
    PayHistory queryById(int id);
    
    @SQL("INSERT INTO PayHistory (memberId,orderId,type,count,memo,createAt) VALUES (:t.memberId,:t.orderId,:t.type,:t.count,:t.memo,now()) ")
    void create(@SQLParam("t") PayHistory payHistory);
}